# coding: utf-8
from typing import Union, Literal

from requests import get

from common import EDGE_USER_AGENT
from .send import RequestBase


def birdClass() -> list:
    return [
        {'name': '4K专区', 'cids': 36},
        {'name': '美女模特', 'cids': 6, 'tags': ['清纯', '性感女神', '欧美女神', '文艺古风']},
        {'name': '爱情', 'cids': 15, 'tags': ['爱情箴言', '浪漫手绘', '心动创意', '唯美温警']},
        {'name': '风景', 'cids': 9,
         'tags': ['蓝天白云', '落日余晖', '春意盎然', '炎炎夏日', '秋意正浓', '冰天雪地', '城市夜景', '海洋天堂',
                  '自然风光', '奇幻梦境']},
        {'name': '小清新', 'cids': 15,
         'tags': ['护眼壁纸', '舒缓压力', '温馨一刻', '清新淡雅', '静物写真', '鸟语花香', '动感水果', '娇艳欲滴']},
        {'name': '动漫', 'cids': 26,
         'tags': ['国漫', '龙珠', '海贼王', '火影忍者', '秦时明月', '进击巨人', '食尸鬼', '卡通人物']},
        {'name': '明星', 'cids': 11,
         'tags': ['肖战', '杨幂', '杨洋', '杨颖', '杨紫', '唐嫣', '刘诗诗', '王一博', '赵丽颖', '张艺兴', 'TFBOYS',
                  '迪丽热巴']},
        {'name': '萌宠', 'cids': 14,
         'tags': ['古灵精怪', '野生动物', '极地物种', '汪星人', '喵星人', '卖萌图', '海底世界', '小鸟天地']},
        {'name': '游戏', 'cids': 5,
         'tags': ['英雄联盟', '王者荣耀', '魔兽世界', '守望先锋', '主机游戏', '手游世界', '热门网游', 'DOTA2']},
        {'name': '汽车', 'cids': 12,
         'tags': ['布加迪', '兰博基尼', '奔驰', '法拉利', '宝马', '路虎', '福特', '宾利', '雪佛兰', '捷豹', '悍马',
                  'JEEP', '玛莎拉蒂', '奥迪', 'MINI', '保时捷', '劳斯莱斯', '克尔维特']},
        {'name': '炫酷时尚', 'cids': 10}, {'name': '日历壁纸', 'cids': 29}, {'name': '影视剧照', 'cids': 7},
        {'name': '节日美图', 'cids': 13}, {'name': '军事天地', 'cids': 22}, {'name': '劲爆体育', 'cids': 16},
        {'name': 'BABY秀', 'cids': 18}, {'name': '文字控', 'cids': 35}
    ]


class BirdAPI(RequestBase):
    """
    小鸟壁纸请求类
    """
    base_url = 'https://wp.shanhutech.cn/intf'
    headers = {'user-agent': EDGE_USER_AGENT}

    @classmethod
    def search(cls, keyword: str = '原神', page: int = 1, *, count: int = 40):
        url = cls.base_url + f'/search'
        params = {
            'content': keyword,
            'pageno': page,
            'count': count
        }
        response = cls.get(url, headers=cls.headers, params=params)
        return response.json()

    @classmethod
    def getListByHotTag(cls, tag: str, page: int = 1, *, count: int = 40):
        """
        按热门标签获取列表
        """
        url = cls.base_url + f'/GetListByHotTag'
        params = {
            'tag': tag,
            'pageno': page,
            'count': count
        }
        response = cls.get(url, headers=cls.headers, params=params)
        return response.json()

    @classmethod
    def getListByCategory(cls, cids: int = 36, page: int = 1, *, count: int = 40):
        """
        按类别获取列表
        """
        url = cls.base_url + f'/GetListByCategory'
        params = {
            'cids': cids,
            'pageno': page,
            'count': count
        }
        response = cls.get(url, headers=cls.headers, params=params)
        return response.json()

    @classmethod
    def newestList(cls, page: int = 1, *, count: int = 40):
        """
        最新的列表
        """
        url = f'https://shcdn-wp.shanhutech.cn/intf/newestList'
        params = {
            'pageno': page,
            'count': count
        }
        response = cls.get(url, headers=cls.headers, params=params)
        return response.json()

    @classmethod
    def getUpOrDownWallpaper(
            cls,
            _id: Union[int, str] = 2059849,
            _type: Literal['newest', 'category', 'tag'] = 'newest',
            value: str = ''
    ):
        """
        :param _id:
        :param _type:
        :params value: cid, tag,(_type, newest时为空)
        """
        url = cls.base_url + f'/GetUpOrDownWallpaper'
        params = {
            'id': _id,
            'value': value,
            'tags': _type,
            'action': ''
        }
        response = cls.get(url, headers=cls.headers, params=params)
        return response.json()


if __name__ == '__main__':
    print(BirdAPI.getListByHotTag('清纯'))
